//
//  AliyunOSSPutObject.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/30.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "AliyunOSSPutObject.h"

@implementation AliyunOSSPutObject

- (NSString *)uuidObjectKeyForType:(GSCPutObjectType)type {
    NSString *uuid = [NSUUID UUID].UUIDString.lowercaseString;
    switch (type) {
        case GSCPutObjectTypeImageJEPG:
        {
            return [uuid stringByAppendingString:@".jpg"];
        }
            break;
        case GSCPutObjectTypeImagePNG:
        {
            return [uuid stringByAppendingString:@".png"];
        }
            break;
        case GSCPutObjectTypeAudioMP3:
        {
            return [uuid stringByAppendingString:@".m4a"];
        }
            break;
        default:
            return nil;
            break;
    }
}

- (NSString *)directoryObjectKeyPath {
    NSString *directoryName;
    switch (self.directoryType) {
        case GSCOSSPutDirectoryTypeNone://如果没设定 放入test文件目录下
        {
            directoryName = @"test";
        }
            break;
        case GSCOSSPutDirectoryTypeBookimg:
        {
            directoryName = @"bookimg";
        }
            break;
        case GSCOSSPutDirectoryTypeConfig:
        {
            directoryName = @"config";
        }
            break;
        case GSCOSSPutDirectoryTypeContract:
        {
            directoryName = @"contract";
        }
            break;
        case GSCOSSPutDirectoryTypeHeader:
        {
            directoryName = @"header";
        }
            break;
        case GSCOSSPutDirectoryTypeIcons:
        {
            directoryName = @"icons";
        }
            break;
        case GSCOSSPutDirectoryTypeMonth:
        {
            directoryName = @"month";
        }
            break;
        case GSCOSSPutDirectoryTypeOther:
        {
            directoryName = @"other";
        }
            break;
        case GSCOSSPutDirectoryTypeSoftwareImage:
        {
            directoryName = @"software_image";
        }
            break;
        case GSCOSSPutDirectoryTypeTest:
        {
            directoryName = @"test";
        }
            break;
        default:
            break;
    }
    if (directoryName) {
        NSString *dateString = [[NSDate date] stringWithFormat:@"yyyy-MM-dd"];
        return [NSString stringWithFormat:@"%@/%@/%@",directoryName,dateString,self.objectKey];
    }else {
        return self.objectKey;
    }
    return nil;
}

@end
